package com.xujl.mvcbind.adapter.provider;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.xujl.fastlib.utils.ImgHelper;
import com.xujl.mvcbind.R;
import com.xujl.mvcbind.bean.TwoMultiEntity;
import com.xujl.mvcbind.util.TimeLog;

import androidx.recyclerview.widget.StaggeredGridLayoutManager;

public class TwoItemBinder extends AbsItemBinder<TwoMultiEntity, BaseViewHolder> {
    private static final String TAG ="TwoItemBinder";
    @Override
    public void convert (BaseViewHolder baseViewHolder, TwoMultiEntity entity) {
        TimeLog.logStart(TAG);
        super.convert(baseViewHolder, entity);
        ImgHelper.loadImgNormal(baseViewHolder.itemView.getContext(), baseViewHolder.getView(R.id.iv), entity.getUrl());
        TimeLog.logEnd(TAG);
    }

    @Override
    public BaseViewHolder onCreateViewHolder (ViewGroup viewGroup, int i) {
        final View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_binder_two, null);
        StaggeredGridLayoutManager.LayoutParams layoutParams = new StaggeredGridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.setFullSpan(true);
        layoutParams.setMargins(10, 10, 10, 10);
        view.setLayoutParams(layoutParams);
        return new BaseViewHolder(view);
    }

}
